package com.wangyg.juc.join.join;

/**
 * Created by wangyg6 on 2018/7/24.
 */
public class Test {

	public static void main(String[] args) throws InterruptedException {
		Thread thread1 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					Thread.sleep(100);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				System.out.println("T1 run");
			}
		});
		Thread thread2 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					thread1.start();
					thread1.join();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				try {
					Thread.sleep(100);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				System.out.println("T2 run");
			}
		});

		Thread thread3 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					thread2.start();
					thread2.join();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				try {
					Thread.sleep(100);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				System.out.println("T3 run");
			}
		});

		Thread.sleep(100);
		thread3.start();
		Thread.sleep(100);

		//		thread1.start();
	}
}
